Namespace DatabaseManager

    Module mDatabaseManager

#Region "Vars"

        Public WithEvents DB_Account As Database.cDataBase
        Public WithEvents DB_Game As Database.cDataBase

        Private mServer As String
        Private mUser As String
        Private mPass As String

#End Region

#Region "Connect"

        Public Function Connect(ByVal server As String, ByVal user As String, ByVal pass As String) As Boolean

            mServer = server
            mUser = user
            mPass = pass

            Try

                WriteDefaultServerIni()

                DB_Account = New DataBase.cDataBase(server, user, pass, 1)
                DB_Game = New DataBase.cDataBase(server, user, pass, 1)

                DB_Account.CheckDatabase("Account")
                DB_Game.CheckDatabase("GameEvo")

                DB_Account.UseDatabase("Account")
                DB_Game.UseDatabase("GameEvo")

                CheckTables_Account()
                CheckTables_Game()

                Return True

            Catch
                MsgBox("Connection to database failed, check login and server state and try again.")
                Return False
            End Try

        End Function

#End Region

#Region "Server Ini"

        Private Sub WriteDefaultServerIni()

            With Main.iniServer

                If .GetString("LOGIN", "IP", "") = "" Then

                    .WriteString("LOGIN", "IP", "127.0.0.1")
                    .WriteString("LOGIN", "PORT", 11100)
                    .WriteString("LOGIN", "MAXATTEMPTS", CStr(5.0))
                    .WriteString("LOGIN", "LOCKOUTTIME", CStr(900.0))

                    .WriteString("SERVERINFO", "NAME", "MIR EVO TEST SERVER")
                    .WriteString("SERVERINFO", "CLIENTVERSION", "MIREVOTESTCLIENT 0.1.0.0")
                    .WriteString("SERVERINFO", "TIMEZONE", "server time")

                    .WriteString("PKMODE", "ALLOWPK", True)
                    .WriteString("PKMODE", "ENABLE_BAG_DROP", True)
                    .WriteString("PKMODE", "BAG_DROP_RATE", CStr(0.05))
                    .WriteString("PKMODE", "ENABLE_BODY_DROP", True)
                    .WriteString("PKMODE", "BODY_DROP_RATE", CStr(0.02))

                End If

            End With

        End Sub

#End Region

#Region "Account"

#Region "Check Tables"

        Public Sub CheckTables_Account()

            CheckTables_Account_TBL_LOGINS()
            CheckTables_Account_TBL_LOCK()
            CheckTables_Account_TBL_BAN()
            CheckTables_Account_TBL_GAMEMASTERLOGINS()
            CheckTables_Account_TBL_GAMEMASTERIPFILTER()

        End Sub

        Private Sub CheckTables_Account_TBL_LOGINS()

            If DB_Account.CheckTable("TBL_LOGINS", _
                            "ID_LOGIN int PRIMARY KEY IDENTITY(1,1), " & _
                            "STR_USERNAME varchar(" & Protocol.MAX_USERNAME_LEN & ") NOT NULL, " & _
                            "STR_PASSMD5 varchar(" & Protocol.MD5PASS_LEN & ") NOT NULL, " & _
                            "STR_EMAIL varchar(" & Protocol.MAX_EMAIL_LEN & ") NOT NULL, " & _
                            "BYTE_ATTEMPTS tinyint NOT NULL, " & _
                            "BYTE_SELECTED tinyint NOT NULL, " & _
                            "BOOL_DELETED bit NOT NULL") Then

            End If

        End Sub

        Private Sub CheckTables_Account_TBL_LOCK()

            DB_Account.CheckTable("TBL_LOCK", _
                        "ID_LOGIN int NOT NULL REFERENCES TBL_LOGINS(ID_LOGIN), " & _
                        "STR_TIMEOUT varchar(20) NOT NULL, " & _
                        "BOOL_DELETED bit NOT NULL")

        End Sub

        Private Sub CheckTables_Account_TBL_BAN()

            DB_Account.CheckTable("TBL_BAN", _
                        "ID_LOGIN int NOT NULL REFERENCES TBL_LOGINS(ID_LOGIN), " & _
                        "BOOL_DELETED bit")

        End Sub

        Private Sub CheckTables_Account_TBL_GAMEMASTERLOGINS()

            If DB_Account.CheckTable("TBL_GAMEMASTERLOGINS", _
                        "ID_LOGIN int NOT NULL REFERENCES TBL_LOGINS(ID_LOGIN), " & _
                        "BOOL_IGNOREFILTER bit NOT NULL, " & _
                        "BOOL_DELETED bit NOT NULL") Then

            End If

        End Sub

        Private Sub CheckTables_Account_TBL_GAMEMASTERIPFILTER()

            DB_Account.CheckTable("TBL_GAMEMASTERIPFILTER", _
                        "STR_IP varchar(15) NOT NULL, " & _
                        "BOOL_DELETED bit NOT NULL")

        End Sub

#End Region

#Region "Account Functions"

        Public Sub CreateAccount()

            Dim username As String, password As String, email As String
            Dim inputok As Boolean

            Do
                username = InputBox("Username:", "New Account")
                If username.Length = 0 Then Exit Sub
                If Not (username.Length >= Protocol.MIN_USERNAME_LEN And username.Length <= Protocol.MAX_USERNAME_LEN) Then
                    MsgBox("Username must be between " & Protocol.MIN_USERNAME_LEN & " & " & Protocol.MAX_USERNAME_LEN & " characters in length.", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly)
                    inputok = False
                Else
                    inputok = True
                End If
            Loop Until inputok

            Do
                password = InputBox("Password:", "New Account")
                If password.Length = 0 Then Exit Sub
                If Not (password.Length >= Protocol.MIN_PASSWORD_LEN And password.Length <= Protocol.MAX_PASSWORD_LEN) Then
                    MsgBox("Password must be between " & Protocol.MIN_PASSWORD_LEN & " & " & Protocol.MAX_PASSWORD_LEN & " characters in length.", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly)
                    inputok = False
                Else
                    inputok = True
                End If
            Loop Until inputok

            Do
                email = InputBox("EMail:", "New Account")
                If email.Length = 0 Then Exit Sub
                If email.Length > Protocol.MAX_EMAIL_LEN Then
                    MsgBox("Email must be under " & Protocol.MAX_EMAIL_LEN & " characters in length.", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly)
                    inputok = False
                ElseIf InStr(email, "@") = 0 Then
                    MsgBox("Email address was not valid!", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly)
                    inputok = False
                ElseIf InStr(InStr(email, "@"), email, ".") = 0 Then
                    MsgBox("Email address was not valid!", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly)
                    inputok = False
                Else
                    inputok = True
                End If
            Loop Until inputok

            Dim cols() As String = {"STR_USERNAME", "STR_PASSMD5", "STR_EMAIL", "BYTE_ATTEMPTS", "BYTE_SELECTED", "BOOL_DELETED"}
            Dim vals() As String = {"'" & username & "'", "'" & Protocol.Functions.MD5Hash(password) & "'", "'" & email & "'", "0", "0", "'FALSE'"}

            DB_Account.NewRecord("TBL_LOGINS", cols, vals)

        End Sub

        Public Sub ResetPassword(ByVal id_login As Integer)

            Dim password As String
            Dim inputok As Boolean

            Do
                password = InputBox("New Password:", "Reset Password:")
                If password.Length = 0 Then Exit Sub
                If Not (password.Length >= Protocol.MIN_PASSWORD_LEN And password.Length <= Protocol.MAX_PASSWORD_LEN) Then
                    MsgBox("Password must be between " & Protocol.MIN_PASSWORD_LEN & " & " & Protocol.MAX_PASSWORD_LEN & " characters in length.", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly)
                    inputok = False
                Else
                    inputok = True
                End If
            Loop Until inputok

            Dim ssql As String = "UPDATE TBL_LOGINS SET STR_PASSMD5='" & Protocol.Functions.MD5Hash(password) & "' WHERE ID_LOGIN=" & id_login & ";"
            DB_Account.ExecuteNonQuery(ssql)

        End Sub

        Public Sub SetGM(ByVal id_login As Integer, ByVal isgm As Boolean)

            Dim ssql As String = "UPDATE TBL_GAMEMASTERLOGINS SET BOOL_DELETED='" & (Not isgm) & "' WHERE ID_LOGIN='" & id_login & "';"

            If DB_Account.ExecuteNonQuery(ssql) = 0 Then

                Dim cols() As String = {"ID_LOGIN", "BOOL_IGNOREFILTER", "BOOL_DELETED"}
                Dim vals() As String = {id_login, "'FALSE'", "'" & (Not isgm) & "'"}

                DB_Account.NewRecord("TBL_GAMEMASTERLOGINS", cols, vals)

            End If

        End Sub

        Public Sub SetGMFilter(ByVal id_login As Integer, ByVal nofilter As Boolean)

            Dim ssql As String = "UPDATE TBL_GAMEMASTERLOGINS SET BOOL_IGNOREFILTER='" & nofilter & "' WHERE ID_LOGIN='" & id_login & "';"
            DB_Account.ExecuteNonQuery(ssql)

        End Sub

        Public Sub RemoveLock(ByVal id_login As Integer)

            Dim ssql As String = "UPDATE TBL_LOCK SET BOOL_DELETED='TRUE' WHERE ID_LOGIN=" & id_login & " AND BOOL_DELETED='FALSE';"
            DB_Account.ExecuteNonQuery(ssql)

        End Sub

        Public Sub SetBan(ByVal id_login As Integer, ByVal banned As Boolean)

            Dim ssql As String = "UPDATE TBL_BAN SET BOOL_DELETED='" & (Not banned) & "' WHERE ID_LOGIN='" & id_login & "';"

            If DB_Account.ExecuteNonQuery(ssql) = 0 Then

                Dim cols() As String = {"ID_LOGIN", "BOOL_DELETED"}
                Dim vals() As String = {id_login, "'" & (Not banned) & "'"}

                DB_Account.NewRecord("TBL_BAN", cols, vals)

            End If

        End Sub

        Public Sub SetDeleted(ByVal id_login As Integer, ByVal deleted As Boolean)

            Dim ssql As String = "UPDATE TBL_LOGINS SET BOOL_DELETED='" & deleted & "' WHERE ID_LOGIN=" & id_login & ";"
            DB_Account.ExecuteNonQuery(ssql)

        End Sub

        Public Function GetIDLogin(ByVal username As String) As Integer
            Dim row As Collection
            row = DB_Account.ExecuteQueryFirstRecord("SELECT ID_LOGIN FROM TBL_LOGINS WHERE STR_USERNAME='" & username & "';")
            If row.Count > 0 Then
                Return row("ID_LOGIN")
            Else
                Return 0
            End If
        End Function

        Public Function GetUsername(ByVal idlogin As Integer) As String
            Dim row As Collection
            row = DB_Account.ExecuteQueryFirstRecord("SELECT STR_USERNAME FROM TBL_LOGINS WHERE ID_LOGIN=" & idlogin & ";")
            If row.Count > 0 Then
                Return row("STR_USERNAME")
            Else
                Return ""
            End If
        End Function

#End Region

#End Region

#Region "Game"

#Region "Check Tables"

        Public Sub CheckTables_Game()

            CheckTables_Game_TBL_CHARACTER()
            CheckTables_Game_TBL_BASESTATS()
            CheckTables_Game_TBL_DEFAULTSTATS()
            CheckTables_Game_TBL_ITEMBASE()
            CheckTables_Game_TBL_ITEMS()
            CheckTables_Game_TBL_MON()
            CheckTables_Game_TBL_MONSPAWN()
            CheckTables_Game_TBL_XSERVERCONN()
            CheckTables_Game_TBL_LEVELS()

            CheckTables_Game_TBL_SKILLBOOK()
            CheckTables_Game_TBL_SKILLLEVELS()
            CheckTables_Game_TBL_SKILLMAPPINGS()
            CheckTables_Game_TBL_SKILLDESC()

        End Sub

        Private Sub CheckTables_Game_TBL_CHARACTER()


            DB_Game.CheckTable("TBL_CHARACTER", _
                                "ID_CHARACTER int PRIMARY KEY IDENTITY(1,1), " & _
                                "ID_LOGIN int NOT NULL, " & _
                                "STR_NAME varchar(" & Protocol.MAX_CHARNAME_LEN & ") NOT NULL, " & _
                                "BOOL_DELETED bit NOT NULL, " & _
                                "STR_CREATED varchar(25) NOT NULL, " & _
                                "STR_LASTLOGIN varchar(25) NOT NULL, " & _
                                "BYTE_JOB tinyint NOT NULL, " & _
                                "BYTE_SEX tinyint NOT NULL, " & _
                                "STR_STORAGEPASSMD5 varchar(" & Protocol.MD5PASS_LEN & ") NOT NULL, " & _
                                "BYTE_HAIR tinyint NOT NULL, " & _
                                "BYTE_HAIRCOL int NOT NULL, " & _
                                "BOOL_SHOWHELM bit NOT NULL, " & _
                                "INT8_GOLD bigint NOT NULL, " & _
                                "INT8_GAMEGOLD bigint NOT NULL, " & _
                                "INT8_FAMEPOINTS bigint NOT NULL, " & _
                                "STR_HOMEMAP varchar(" & Protocol.MAX_MAPNAME_LEN & ") NOT NULL")

        End Sub

        Private Sub CheckTables_Game_TBL_BASESTATS()

            'TODO: cleanup & finalize table
            DB_Game.CheckTable("TBL_BASESTATS", _
            "ID_CHARACTER int NOT NULL REFERENCES TBL_CHARACTER(ID_CHARACTER), " & _
            "INT2_LEVEL smallint NOT NULL, " & _
            "INT8_EXP bigint NOT NULL, " & _
            "INT1_EXPBONUS tinyint NOT NULL, " & _
            "INT2_MIN_AC smallint NOT NULL, " & _
            "INT2_MIN_MAC smallint NOT NULL, " & _
            "INT2_MIN_DC smallint NOT NULL, " & _
            "INT2_MIN_MC smallint NOT NULL, " & _
            "INT2_MIN_SC smallint NOT NULL, " & _
            "INT2_MAX_HP smallint NOT NULL, " & _
            "INT2_MAX_MP smallint NOT NULL, " & _
            "INT2_MAX_AC smallint NOT NULL, " & _
            "INT2_MAX_MAC smallint NOT NULL, " & _
            "INT2_MAX_DC smallint NOT NULL, " & _
            "INT2_MAX_MC smallint NOT NULL, " & _
            "INT2_MAX_SC smallint NOT NULL, " & _
            "INT2_MAX_WEIGHT smallint NOT NULL, " & _
            "INT2_MAX_HANDWEIGHT smallint NOT NULL, " & _
            "INT2_MAX_WEARWEIGHT smallint NOT NULL, " & _
            "INT2_ELEMC_FIRE smallint NOT NULL, " & _
            "INT2_ELEMC_ICE smallint NOT NULL, " & _
            "INT2_ELEMC_LIGHT smallint NOT NULL, " & _
            "INT2_ELEMC_WIND smallint NOT NULL, " & _
            "INT2_ELEMC_HOLY smallint NOT NULL, " & _
            "INT2_ELEMC_DARK smallint NOT NULL, " & _
            "INT2_ELEMC_PHANTOM smallint NOT NULL, " & _
            "INT2_ELEMAC_FIRE smallint NOT NULL, " & _
            "INT2_ELEMAC_ICE smallint NOT NULL, " & _
            "INT2_ELEMAC_LIGHT smallint NOT NULL, " & _
            "INT2_ELEMAC_WIND smallint NOT NULL, " & _
            "INT2_ELEMAC_HOLY smallint NOT NULL, " & _
            "INT2_ELEMAC_DARK smallint NOT NULL, " & _
            "INT2_ELEMAC_PHANTOM smallint NOT NULL, " & _
            "INT1_ACCURACY tinyint NOT NULL, " & _
            "INT1_AGILITY tinyint NOT NULL, " & _
            "INT1_VELOCITY tinyint NOT NULL, " & _
            "INT1_BODYLUCK tinyint NOT NULL" & _
            "INT8_HPREGENTICK bigint NOT NULL" & _
            "INT8_MPREGENTICK bigint NOT NULL" & _
            "INT8_HPREGENAMMOUNT int NOT NULL" & _
            "INT8_MPREGENAMMOUNT int NOT NULL")

        End Sub

        Private Sub CheckTables_Game_TBL_DEFAULTSTATS()

            If DB_Game.CheckTable("TBL_DEFAULTSTATS", _
            "BYTE_JOB tinyint NOT NULL, " & _
            "INT2_LEVEL smallint NOT NULL, " & _
            "INT8_EXP bigint NOT NULL, " & _
            "INT1_EXPBONUS tinyint NOT NULL, " & _
            "INT2_MIN_AC smallint NOT NULL, " & _
            "INT2_MIN_MAC smallint NOT NULL, " & _
            "INT2_MIN_DC smallint NOT NULL, " & _
            "INT2_MIN_MC smallint NOT NULL, " & _
            "INT2_MIN_SC smallint NOT NULL, " & _
            "INT2_MAX_HP smallint NOT NULL, " & _
            "INT2_MAX_MP smallint NOT NULL, " & _
            "INT2_MAX_AC smallint NOT NULL, " & _
            "INT2_MAX_MAC smallint NOT NULL, " & _
            "INT2_MAX_DC smallint NOT NULL, " & _
            "INT2_MAX_MC smallint NOT NULL, " & _
            "INT2_MAX_SC smallint NOT NULL, " & _
            "INT2_MAX_WEIGHT smallint NOT NULL, " & _
            "INT2_MAX_HANDWEIGHT smallint NOT NULL, " & _
            "INT2_MAX_WEARWEIGHT smallint NOT NULL, " & _
            "INT2_ELEMC_FIRE smallint NOT NULL, " & _
            "INT2_ELEMC_ICE smallint NOT NULL, " & _
            "INT2_ELEMC_LIGHT smallint NOT NULL, " & _
            "INT2_ELEMC_WIND smallint NOT NULL, " & _
            "INT2_ELEMC_HOLY smallint NOT NULL, " & _
            "INT2_ELEMC_DARK smallint NOT NULL, " & _
            "INT2_ELEMC_PHANTOM smallint NOT NULL, " & _
            "INT2_ELEMAC_FIRE smallint NOT NULL, " & _
            "INT2_ELEMAC_ICE smallint NOT NULL, " & _
            "INT2_ELEMAC_LIGHT smallint NOT NULL, " & _
            "INT2_ELEMAC_WIND smallint NOT NULL, " & _
            "INT2_ELEMAC_HOLY smallint NOT NULL, " & _
            "INT2_ELEMAC_DARK smallint NOT NULL, " & _
            "INT2_ELEMAC_PHANTOM smallint NOT NULL, " & _
            "INT1_ACCURACY tinyint NOT NULL, " & _
            "INT1_AGILITY tinyint NOT NULL, " & _
            "INT1_VELOCITY tinyint NOT NULL, " & _
            "INT1_BODYLUCK tinyint NOT NULL, " & _
            "INT8_HPREGENTICK bigint NOT NULL, " & _
            "INT8_MPREGENTICK bigint NOT NULL, " & _
            "INT8_HPREGENAMMOUNT bigint NOT NULL, " & _
            "INT8_MPREGENAMMOUNT bigint NOT NULL") Then

                'hp: 5 mp: 2 wgt: 6, 1, 1
                Dim hp As Long, mp As Long, bagwgt As Long, handwgt As Long, wearwgt As Long, acc As Long, agil As Long, vel As Long
                Dim lvl As Integer = 1

                Do

                    DefaultStatsSet(EvoLib.Protocol.mProtocol.CharacterJobs.Warrior, lvl, 0, 0, 1, 0, _
                        2, 0, 0, hp + 21, mp + 10, 2, _
                        1, 4, 1, 1, (bagwgt * 6) + 25, (handwgt * 3) + 10, _
                        (wearwgt * 3) + 8, 0, 0, 0, 0, 0, _
                        0, 0, 0, 0, 0, 0, _
                        0, 0, 0, acc + 5, agil + 15, vel + 15, _
                        192, 15000000, 150000000, 3, 2)

                    DefaultStatsSet(Protocol.CharacterJobs.Sorcerer, lvl, 0, 0, 0, 1, _
                                        2, 1, 0, hp + 10, mp + 21, 1, _
                                        2, 3, 2, 1, (bagwgt * 4) + 19, handwgt + 7, _
                                        wearwgt + 7, 0, 0, 0, 0, 0, _
                                        0, 0, 0, 0, 0, 0, _
                                        0, 0, 0, acc + 5, agil + 15, vel + 15, _
                                        192, 15000000, 150000000, 1, 7)

                    DefaultStatsSet(Protocol.CharacterJobs.Taoist, lvl, 0, 0, 1, 1, _
                                        2, 0, 1, hp + 16, mp + 15, 1, _
                                        1, 3, 1, 2, (bagwgt * 5) + 22, (handwgt * 2) + 9, _
                                        (wearwgt * 2) + 7, 0, 0, 0, 0, 0, _
                                        0, 0, 0, 0, 0, 0, _
                                        0, 0, 0, acc + 5, agil + 15, vel + 15, _
                                        192, 15000000, 150000000, 2, 5)


                    'Math.DivRem(lvl, 3, R)
                    'If R = 0 Then
                    'acc += 1
                    'agil += 1
                    'vel += 1
                    'End If

                    hp += 5
                    mp += 2
                    bagwgt += 1
                    handwgt += 1
                    wearwgt += 1
                    lvl += 1

                Loop Until lvl > 23

            End If

        End Sub

        Private Sub DefaultStatsSet(BYTE_JOB As Protocol.CharacterJobs, INT2_LEVEL As Int64, INT8_EXP As Int64, INT1_EXPBONUS As Int64, INT2_MIN_AC As Int64, INT2_MIN_MAC As Int64, _
                                INT2_MIN_DC As Int64, INT2_MIN_MC As Int64, INT2_MIN_SC As Int64, INT2_MAX_HP As Int64, INT2_MAX_MP As Int64, INT2_MAX_AC As Int64, _
                                INT2_MAX_MAC As Int64, INT2_MAX_DC As Int64, INT2_MAX_MC As Int64, INT2_MAX_SC As Int64, INT2_MAX_WEIGHT As Int64, INT2_MAX_HANDWEIGHT As Int64, _
                                INT2_MAX_WEARWEIGHT As Int64, INT2_ELEMC_FIRE As Int64, INT2_ELEMC_ICE As Int64, INT2_ELEMC_LIGHT As Int64, INT2_ELEMC_WIND As Int64, INT2_ELEMC_HOLY As Int64, _
                                INT2_ELEMC_DARK As Int64, INT2_ELEMC_PHANTOM As Int64, INT2_ELEMAC_FIRE As Int64, INT2_ELEMAC_ICE As Int64, INT2_ELEMAC_LIGHT As Int64, INT2_ELEMAC_WIND As Int64, _
                                INT2_ELEMAC_HOLY As Int64, INT2_ELEMAC_DARK As Int64, INT2_ELEMAC_PHANTOM As Int64, INT1_ACCURACY As Int64, INT1_AGILITY As Int64, INT1_VELOCITY As Int64, _
                                INT1_BODYLUCK As Int64, INT8_HPREGENTICK As Int64, INT8_MPREGENTICK As Int64, INT8_HPREGENAMMOUNT As Int64, INT8_MPREGENAMMOUNT As Int64)

            Dim cols() As String = {"BYTE_JOB", "INT2_LEVEL", "INT8_EXP", "INT1_EXPBONUS", "INT2_MIN_AC", "INT2_MIN_MAC", _
                                "INT2_MIN_DC", "INT2_MIN_MC", "INT2_MIN_SC", "INT2_MAX_HP", "INT2_MAX_MP", "INT2_MAX_AC", _
                                "INT2_MAX_MAC", "INT2_MAX_DC", "INT2_MAX_MC", "INT2_MAX_SC", "INT2_MAX_WEIGHT", "INT2_MAX_HANDWEIGHT", _
                                "INT2_MAX_WEARWEIGHT", "INT2_ELEMC_FIRE", "INT2_ELEMC_ICE", "INT2_ELEMC_LIGHT", "INT2_ELEMC_WIND", "INT2_ELEMC_HOLY", _
                                "INT2_ELEMC_DARK", "INT2_ELEMC_PHANTOM", "INT2_ELEMAC_FIRE", "INT2_ELEMAC_ICE", "INT2_ELEMAC_LIGHT", "INT2_ELEMAC_WIND", _
                                "INT2_ELEMAC_HOLY", "INT2_ELEMAC_DARK", "INT2_ELEMAC_PHANTOM", "INT1_ACCURACY", "INT1_AGILITY", "INT1_VELOCITY", _
                                "INT1_BODYLUCK", "INT8_HPREGENTICK", "INT8_MPREGENTICK", "INT8_HPREGENAMMOUNT", "INT8_MPREGENAMMOUNT"}

            Dim vals() As String = {BYTE_JOB, INT2_LEVEL, INT8_EXP, INT1_EXPBONUS, INT2_MIN_AC, INT2_MIN_MAC, _
                                INT2_MIN_DC, INT2_MIN_MC, INT2_MIN_SC, INT2_MAX_HP, INT2_MAX_MP, INT2_MAX_AC, _
                                INT2_MAX_MAC, INT2_MAX_DC, INT2_MAX_MC, INT2_MAX_SC, INT2_MAX_WEIGHT, INT2_MAX_HANDWEIGHT, _
                                INT2_MAX_WEARWEIGHT, INT2_ELEMC_FIRE, INT2_ELEMC_ICE, INT2_ELEMC_LIGHT, INT2_ELEMC_WIND, INT2_ELEMC_HOLY, _
                                INT2_ELEMC_DARK, INT2_ELEMC_PHANTOM, INT2_ELEMAC_FIRE, INT2_ELEMAC_ICE, INT2_ELEMAC_LIGHT, INT2_ELEMAC_WIND, _
                                INT2_ELEMAC_HOLY, INT2_ELEMAC_DARK, INT2_ELEMAC_PHANTOM, INT1_ACCURACY, INT1_AGILITY, INT1_VELOCITY, _
                                INT1_BODYLUCK, INT8_HPREGENTICK, INT8_MPREGENTICK, INT8_HPREGENAMMOUNT, INT8_MPREGENAMMOUNT}

            DB_Game.NewRecord("TBL_DEFAULTSTATS", cols, vals)


        End Sub

        Private Sub CheckTables_Game_TBL_ITEMBASE()

            If DB_Game.CheckTable("TBL_ITEMBASE", _
                                "ID_ITEMBASE int PRIMARY KEY IDENTITY(1,1), " & _
                                "STR_NAME varchar(" & Protocol.MAX_ITEMNAME_LEN & ") NOT NULL, " & _
                                "BYTE_TYPE tinyint NOT NULL, " & _
                                "INT_SHAPE int NOT NULL, " & _
                                "INT_LOOKS int NOT NULL, " & _
                                "BOOL_STACKS bit NOT NULL, " & _
                                "INT_STDITEM int NOT NULL, " & _
                                "INT8_COST bigint NOT NULL, " & _
                                "INT2_LEVELREQ smallint NOT NULL, " & _
                                "INT2_WEIGHT smallint NOT NULL, " & _
                                "BYTE_ITEMCLASS tinyint NOT NULL, " & _
                                "INT1_EXPBONUS tinyint NOT NULL, " & _
                                "INT2_MIN_AC smallint NOT NULL, " & _
                                "INT2_MIN_MAC smallint NOT NULL, " & _
                                "INT2_MIN_DC smallint NOT NULL, " & _
                                "INT2_MIN_MC smallint NOT NULL, " & _
                                "INT2_MIN_SC smallint NOT NULL, " & _
                                "INT2_MAX_HP smallint NOT NULL, " & _
                                "INT2_MAX_MP smallint NOT NULL, " & _
                                "INT2_MAX_AC smallint NOT NULL, " & _
                                "INT2_MAX_MAC smallint NOT NULL, " & _
                                "INT2_MAX_DC smallint NOT NULL, " & _
                                "INT2_MAX_MC smallint NOT NULL, " & _
                                "INT2_MAX_SC smallint NOT NULL, " & _
                                "INT2_MAX_WEIGHT smallint NOT NULL, " & _
                                "INT2_MAX_HANDWEIGHT smallint NOT NULL, " & _
                                "INT2_MAX_WEARWEIGHT smallint NOT NULL, " & _
                                "INT2_ELEMC_FIRE smallint NOT NULL, " & _
                                "INT2_ELEMC_ICE smallint NOT NULL, " & _
                                "INT2_ELEMC_LIGHT smallint NOT NULL, " & _
                                "INT2_ELEMC_WIND smallint NOT NULL, " & _
                                "INT2_ELEMC_HOLY smallint NOT NULL, " & _
                                "INT2_ELEMC_DARK smallint NOT NULL, " & _
                                "INT2_ELEMC_PHANTOM smallint NOT NULL, " & _
                                "INT2_ELEMAC_FIRE smallint NOT NULL, " & _
                                "INT2_ELEMAC_ICE smallint NOT NULL, " & _
                                "INT2_ELEMAC_LIGHT smallint NOT NULL, " & _
                                "INT2_ELEMAC_WIND smallint NOT NULL, " & _
                                "INT2_ELEMAC_HOLY smallint NOT NULL, " & _
                                "INT2_ELEMAC_DARK smallint NOT NULL, " & _
                                "INT2_ELEMAC_PHANTOM smallint NOT NULL, " & _
                                "INT1_ACCURACY tinyint NOT NULL, " & _
                                "INT1_AGILITY tinyint NOT NULL, " & _
                                "INT1_VELOCITY tinyint NOT NULL, " & _
                                "INT_MAX_DURABILITY int NOT NULL, " & _
                                "INT1_STRENGTH tinyint NOT NULL, " & _
                                "INT1_LUCK tinyint NOT NULL") Then

                CreateDefaultItems()


                'Else

                '    Dim ssql As String = "SELECT * FROM TBL_ITEMBASE;"
                '    Dim arr As ArrayList = DB_Game.ExecuteQuery(ssql)
                '    Dim strcreate As String

                '    If arr.Count > 0 Then
                '        For i As Integer = 0 To arr.Count - 1

                '            strcreate = "CreateItem(" & Chr(34) & arr(i)(2) & Chr(34) & ", "

                '            For idx As Integer = 3 To arr(i).count
                '                strcreate &= arr(i)(idx).ToString() & ", "
                '                If idx = 6 Then
                '                    strcreate &= "COST, "
                '                End If
                '            Next

                '            strcreate = Left(strcreate, strcreate.Length - 2)
                '            strcreate &= ")"

                '            Debug.Print(strcreate)

                '        Next


            End If


        End Sub

        Public Sub CreateDefaultItems()

            Dim returns As New Collection

            'starter armors
            returns.Add(CreateItem("Basic Dress (M)", Protocol.ItemType.MArmor, 2, 942, False, 500, 0, 1, 5, Protocol.ItemClass.Normal, 0, 2, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0))
            returns.Add(CreateItem("Basic Dress (F)", Protocol.ItemType.FArmor, 2, 952, False, 500, 0, 1, 5, Protocol.ItemClass.Normal, 0, 2, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0))
            'improved starter armors
            returns.Add(CreateItem("Improved Basic Dress (M)", Protocol.ItemType.MArmor, 1, 941, False, 3000, 0, 6, 6, Protocol.ItemClass.Superior, 0, 2, 0, 0, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0))
            returns.Add(CreateItem("Improved Basic Dress (F)", Protocol.ItemType.FArmor, 1, 951, False, 3000, 0, 6, 6, Protocol.ItemClass.Superior, 0, 2, 0, 0, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0))
            returns.Add(CreateItem("Durable Light Armor (M)", Protocol.ItemType.MArmor, 2, 942, False, 100, 0, 11, 8, Protocol.ItemClass.Superior, 0, 3, 1, 0, 0, 0, 0, 0, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0))
            returns.Add(CreateItem("Durable Light Armor (F)", Protocol.ItemType.FArmor, 2, 952, False, 100, 0, 11, 8, Protocol.ItemClass.Superior, 0, 3, 1, 0, 0, 0, 0, 0, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0))
            'lvl 11 armors
            returns.Add(CreateItem("Light Armor (M)", Protocol.ItemType.MArmor, 2, 943, False, 5000, 0, 11, 8, Protocol.ItemClass.Normal, 0, 3, 1, 0, 0, 0, 0, 0, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0))
            returns.Add(CreateItem("Light Armor (F)", Protocol.ItemType.FArmor, 2, 953, False, 5000, 0, 11, 8, Protocol.ItemClass.Normal, 0, 3, 1, 0, 0, 0, 0, 0, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0))
            'improved lvl 11 armors
            returns.Add(CreateItem("Improved Light Armor (M)", Protocol.ItemType.MArmor, 2, 942, False, 8000, 0, 16, 10, Protocol.ItemClass.Superior, 0, 3, 1, 0, 0, 0, 0, 0, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0))
            returns.Add(CreateItem("Improved Light Armor (F)", Protocol.ItemType.FArmor, 2, 952, False, 8000, 0, 16, 10, Protocol.ItemClass.Superior, 0, 3, 1, 0, 0, 0, 0, 0, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0))
            'lvl 22 armors
            returns.Add(CreateItem("Medium Armor (M)", Protocol.ItemType.MArmor, 3, 981, False, 7000, 0, 22, 23, Protocol.ItemClass.Normal, 0, 4, 2, 0, 0, 0, 0, 0, 9, 3, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 0, 0))
            returns.Add(CreateItem("Medium Armor (F)", Protocol.ItemType.FArmor, 3, 991, False, 7000, 0, 22, 23, Protocol.ItemClass.Normal, 0, 4, 2, 0, 0, 0, 0, 0, 9, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25, 0, 0))
            returns.Add(CreateItem("Flame Robe (M)", Protocol.ItemType.MArmor, 4, 1021, False, 10000, 0, 22, 12, Protocol.ItemClass.Normal, 0, 3, 3, 0, 0, 0, 0, 0, 7, 4, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0))
            returns.Add(CreateItem("Flame Robe (F)", Protocol.ItemType.FArmor, 4, 1031, False, 10000, 0, 22, 12, Protocol.ItemClass.Normal, 0, 3, 3, 0, 0, 0, 0, 0, 7, 4, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0))
            returns.Add(CreateItem("Taoist Robe (M)", Protocol.ItemType.MArmor, 5, 1001, False, 10000, 0, 22, 15, Protocol.ItemClass.Normal, 0, 3, 3, 0, 0, 0, 0, 0, 8, 3, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0))
            returns.Add(CreateItem("Taoist Robe (F)", Protocol.ItemType.FArmor, 5, 1011, False, 10000, 0, 22, 15, Protocol.ItemClass.Normal, 0, 3, 3, 0, 0, 0, 0, 0, 8, 3, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0))
            'gm armors
            returns.Add(CreateItem("GM Robe (M)", Protocol.ItemType.MArmor, 11, 963, False, 1000000, 0, 1, 1, Protocol.ItemClass.Rare, , 5, 4, 3, 2, 2, 1000, 700, 10, 8, 3, 2, 2, , , , , , , , , , , , , , , , , , , , , 22))
            returns.Add(CreateItem("GM Robe (F)", Protocol.ItemType.FArmor, 11, 973, False, 1000000, 0, 1, 1, Protocol.ItemClass.Rare, , 5, 4, 3, 2, 2, 1000, 700, 10, 8, 3, 2, 2, , , , , , , , , , , , , , , , , , , , , 22))

            'starter weaps
            returns.Add(CreateItem("Wooden Sword", Protocol.ItemType.Weapon, 8, 1043, False, 50, 0, 1, 5, Protocol.ItemClass.Normal, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0))
            returns.Add(CreateItem("Dagger", Protocol.ItemType.Weapon, 73, 1046, False, 100, 0, 3, 7, Protocol.ItemClass.Normal, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0))
            returns.Add(CreateItem("Bronze Sword", Protocol.ItemType.Weapon, 26, 1044, False, 500, 0, 5, 9, Protocol.ItemClass.Normal, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0))
            returns.Add(CreateItem("Arisu Sword", Protocol.ItemType.Weapon, 8, 1043, False, 1000, 0, 7, 5, Protocol.ItemClass.Normal, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0))
            returns.Add(CreateItem("Iron Sword", Protocol.ItemType.Weapon, 26, 1044, False, 1000, 0, 7, 10, Protocol.ItemClass.Normal, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0))
            'lvl 14 weaps
            returns.Add(CreateItem("Bronze Axe", Protocol.ItemType.Weapon, 72, 1061, False, 3500, 0, 14, 20, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0))
            returns.Add(CreateItem("Scimitar", Protocol.ItemType.Weapon, 74, 1100, False, 3500, 0, 14, 13, Protocol.ItemClass.Normal, 0, 0, 0, 4, 0, 1, 0, 0, 0, 0, 10, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0))
            returns.Add(CreateItem("Trident", Protocol.ItemType.Weapon, 70, 1080, False, 3500, 0, 14, 10, Protocol.ItemClass.Normal, 0, 0, 0, 3, 1, 0, 0, 0, 0, 0, 10, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0))
            'lvl 17/18 weaps
            returns.Add(CreateItem("Steel Sword", Protocol.ItemType.Weapon, 26, 1064, False, 4500, 0, 17, 23, Protocol.ItemClass.Normal, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0))
            returns.Add(CreateItem("Hooked Blade", Protocol.ItemType.Weapon, 26, 1064, False, 5000, 0, 18, 27, Protocol.ItemClass.Normal, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0))
            returns.Add(CreateItem("Broad Bladed Spear", Protocol.ItemType.Weapon, 5, 1082, False, 5000, 0, 18, 11, Protocol.ItemClass.Normal, 0, 0, 0, 4, 1, 0, 0, 0, 0, 0, 10, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0))
            returns.Add(CreateItem("Kriss Sword", Protocol.ItemType.Weapon, 29, 1102, False, 5000, 0, 18, 15, Protocol.ItemClass.Normal, 0, 0, 0, 5, 0, 1, 0, 0, 0, 0, 12, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 0))
            'gm weaps
            returns.Add(CreateItem("GM Blade", EvoLib.Protocol.mProtocol.ItemType.Weapon, 43, 1079, False, 1000000, 0, 1, 1, Protocol.ItemClass.Rare, , , , 100, 5, 5, , , , , 150, 30, 30, , , , , , , , , , , , , , , , , , , , , 44))



            'starter helmets
            returns.Add(CreateItem("Bronze Helmet", Protocol.ItemType.Helmet, 0, 371, False, 1000, 0, 9, 4, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0))
            returns.Add(CreateItem("Magic Bronze Helmet", Protocol.ItemType.Helmet, 0, 371, False, 3000, 0, 15, 4, Protocol.ItemClass.Normal, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0))
            'higher lvl helmets
            returns.Add(CreateItem("Blessed Bronze Helmet", Protocol.ItemType.Helmet, 0, 371, False, 5000, 0, 18, 4, Protocol.ItemClass.Normal, , , , , , , , , 2, 1, , , , , , , , , , , , , , , , , , , , , , , , 8, , ))
            returns.Add(CreateItem("Skeleton Helmet", Protocol.ItemType.Helmet, 0, 374, False, 8000, 0, 20, 5, Protocol.ItemClass.Normal, , 2, , , , , , , 3, , , , , , , , , , , , , , , , , , , , , , , , , 8, , ))
            returns.Add(CreateItem("Braided Hat", Protocol.ItemType.Helmet, 0, 412, False, 8000, 0, 20, 4, Protocol.ItemClass.Normal, , 1, 3, , , , , , 3, 4, , , , , , , , , , , , , , , , , , , , , , , , 8, , ))
            'superior helmets
            returns.Add(CreateItem("Blessed Braided Hat", Protocol.ItemType.Helmet, 0, 412, False, 12000, 0, 11, 4, Protocol.ItemClass.Superior, 0, 2, 4, , , , , , 4, 5, , , , , , , , , , , , , , , , , , , , , , , , 9))
            returns.Add(CreateItem("Blessed Skeleton Helmet", Protocol.ItemType.Helmet, 0, 374, False, 12000, 0, 11, 5, Protocol.ItemClass.Superior, 0, 3, , , , , , , 5, , , , , , , , , , , , , , , , , , , , , , , , , 9))


            'starter neckys
            returns.Add(CreateItem("Golden Necklace", Protocol.ItemType.Necklace, 0, 871, False, 200, 0, 2, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0))
            returns.Add(CreateItem("Precision Necklace", Protocol.ItemType.Necklace, 0, 874, False, 300, 0, 3, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 8, 0, 0))
            returns.Add(CreateItem("White Gold Necklace", Protocol.ItemType.Necklace, 0, 852, False, 3000, 0, 10, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0))
            '11 neckys
            returns.Add(CreateItem("Arisu Necklace", Protocol.ItemType.Necklace, 0, 851, False, 4000, 0, 11, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0))
            returns.Add(CreateItem("Crystal Necklace", Protocol.ItemType.Necklace, 0, 855, False, 4000, 0, 11, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0))
            returns.Add(CreateItem("Black Crystal Necklace", Protocol.ItemType.Necklace, 0, 811, False, 4000, 0, 11, 1, Protocol.ItemClass.Normal, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0))
            returns.Add(CreateItem("Green Crystal Necklace", Protocol.ItemType.Necklace, 0, 831, False, 4000, 0, 11, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0))
            '15 neckys
            returns.Add(CreateItem("Meditation Necklace", Protocol.ItemType.Necklace, 0, 857, False, 5000, 0, 15, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0))
            returns.Add(CreateItem("Nanga Necklace", Protocol.ItemType.Necklace, 0, 812, False, 5000, 0, 15, 1, Protocol.ItemClass.Normal, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0))
            returns.Add(CreateItem("Amber Necklace", Protocol.ItemType.Necklace, 0, 853, False, 5000, 0, 15, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0))
            '19 neckys
            returns.Add(CreateItem("Phoenix Bead", Protocol.ItemType.Necklace, 0, 832, False, 7000, 0, 19, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0))
            returns.Add(CreateItem("Purple Jade Necklace", Protocol.ItemType.Necklace, 0, 838, False, 7000, 0, 19, 1, Protocol.ItemClass.Normal, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0))
            returns.Add(CreateItem("Five Colour Necklace", Protocol.ItemType.Necklace, 0, 914, False, 7000, 0, 19, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0))
            'superior neckys
            returns.Add(CreateItem("Magic Mirror", EvoLib.Protocol.mProtocol.ItemType.Necklace, 0, 854, False, 11000, 0, 11, 1, Protocol.ItemClass.Superior, , , , , 1, , , , , , , 4, , , , , , , , , , , , , , , , , , , , , , 7))
            returns.Add(CreateItem("Soul Necklace", EvoLib.Protocol.mProtocol.ItemType.Necklace, 0, 896, False, 11000, 0, 11, 1, Protocol.ItemClass.Superior, , , , , , 2, , , , , , , 3, , , , , , , , , , , , , , , , , , , , , 8))
            returns.Add(CreateItem("Power Necklace", EvoLib.Protocol.mProtocol.ItemType.Necklace, 0, 880, False, 11000, 0, 11, 1, Protocol.ItemClass.Superior, , , , 1, , , , , , , 4, , , , , , , , , , , , , , , , , , , , , , , 10))


            'starter rings
            returns.Add(CreateItem("Rusted Ring", Protocol.ItemType.Ring, 0, 531, False, 500, 0, 5, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0))
            returns.Add(CreateItem("Copper Ring", Protocol.ItemType.Ring, 0, 531, False, 1000, 0, 7, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0))
            returns.Add(CreateItem("Glass Ring", Protocol.ItemType.Ring, 0, 491, False, 1000, 0, 7, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0))
            returns.Add(CreateItem("Hexagonal Ring", Protocol.ItemType.Ring, 0, 511, False, 1000, 0, 7, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0))

            returns.Add(CreateItem("Horn Ring", Protocol.ItemType.Ring, 0, 471, False, 1200, 0, 8, 1, Protocol.ItemClass.Superior, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0))
            returns.Add(CreateItem("Iron Ring", Protocol.ItemType.Ring, 0, 472, False, 2000, 0, 9, 1, Protocol.ItemClass.Superior, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0))
            '13 rings
            returns.Add(CreateItem("Pearl Ring", Protocol.ItemType.Ring, 0, 492, False, 2500, 0, 13, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0))
            returns.Add(CreateItem("Black Crystal", Protocol.ItemType.Ring, 0, 532, False, 2500, 0, 13, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0))
            returns.Add(CreateItem("Gold Snake Eye", Protocol.ItemType.Ring, 0, 512, False, 2500, 0, 13, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0))
            '\
            returns.Add(CreateItem("Black Pearl", Protocol.ItemType.Ring, 0, 532, False, 5000, 0, 15, 1, Protocol.ItemClass.Normal, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0))
            '17 rings
            returns.Add(CreateItem("White Gold Ring", Protocol.ItemType.Ring, 0, 494, False, 10000, 0, 17, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0))
            returns.Add(CreateItem("Ruby Ring", Protocol.ItemType.Ring, 0, 514, False, 10000, 0, 17, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0))
            returns.Add(CreateItem("Coral Ring", EvoLib.Protocol.mProtocol.ItemType.Ring, 0, 534, False, 10000, 0, 17, 1, Protocol.ItemClass.Normal, , , , 1, , , , , , , 2, , , , , , , , , , , , , , , , , , , , , , , 7))
            '19 rings
            returns.Add(CreateItem("White Snake Ring", Protocol.ItemType.Ring, 0, 512, False, 16000, 0, 19, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0))
            returns.Add(CreateItem("Blue Pearl Ring", Protocol.ItemType.Ring, 0, 492, False, 16000, 0, 19, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0))
            returns.Add(CreateItem("Skeleton Ring", EvoLib.Protocol.mProtocol.ItemType.Ring, 0, 533, False, 16000, 0, 19, 1, Protocol.ItemClass.Normal, , , , 1, , , , , , , 3, , , , , , , , , , , , , , , , , , , , , , , 10))
            'superior rings
            returns.Add(CreateItem("Destruction Ring", EvoLib.Protocol.mProtocol.ItemType.Ring, 0, 536, False, 19000, 0, 11, 2, Protocol.ItemClass.Superior, , , , 2, , , , , , , 4, , , , , , , , , , , , , , , , , , , , , , , 11))
            returns.Add(CreateItem("Spirit Ring", EvoLib.Protocol.mProtocol.ItemType.Ring, 0, 495, False, 19000, 0, 11, 1, Protocol.ItemClass.Superior, , , , , , 1, , , , , , , 5, , , , , , , , , , , , , , , , , , , , , 9))
            returns.Add(CreateItem("Spell Ring", EvoLib.Protocol.mProtocol.ItemType.Ring, 0, 515, False, 19000, 0, 11, 1, Protocol.ItemClass.Superior, , , , , 1, , , , , , , 5, , , , , , , , , , , , , , , , , , , , , , 8))


            'starter bracers
            returns.Add(CreateItem("Thin Bracelet", Protocol.ItemType.Bracer, 0, 649, False, 400, 0, 4, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0))
            returns.Add(CreateItem("Leather Glove", Protocol.ItemType.Bracer, 0, 641, False, 500, 0, 5, 2, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0))
            returns.Add(CreateItem("Iron Soul Band", Protocol.ItemType.Bracer, 0, 647, False, 1000, 0, 8, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0))
            returns.Add(CreateItem("Large Bracelet", Protocol.ItemType.Bracer, 0, 645, False, 1500, 0, 9, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0))
            '10 bracers
            returns.Add(CreateItem("Tao Bracelet", Protocol.ItemType.Bracer, 0, 681, False, 2000, 0, 10, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0))
            returns.Add(CreateItem("Arisu Bracelet", Protocol.ItemType.Bracer, 0, 701, False, 2000, 0, 10, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0))
            returns.Add(CreateItem("Fighter Bracelet", Protocol.ItemType.Bracer, 0, 661, False, 2000, 0, 10, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0))
            returns.Add(CreateItem("Shout Bracelet", Protocol.ItemType.Bracer, 0, 701, False, 2000, 0, 10, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0))
            'mid range
            returns.Add(CreateItem("Flame Tree Band", Protocol.ItemType.Bracer, 0, 701, False, 100, 0, 11, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0))
            returns.Add(CreateItem("Magic Bracelet", Protocol.ItemType.Bracer, 0, 648, False, 2500, 0, 12, 1, Protocol.ItemClass.Normal, 0, 0, 1, 0, 0, 0, 0, 0, 1, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0))
            returns.Add(CreateItem("Strain Bracelet", Protocol.ItemType.Bracer, 0, 661, False, 3000, 0, 15, 1, Protocol.ItemClass.Normal, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0))
            returns.Add(CreateItem("Hard Arisu Bracelet", Protocol.ItemType.Bracer, 0, 701, False, 4000, 0, 16, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0))
            returns.Add(CreateItem("Wild Bracelet", Protocol.ItemType.Bracer, 0, 701, False, 4000, 0, 16, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0))
            '17 bracers
            returns.Add(CreateItem("Ripple Bracelet", Protocol.ItemType.Bracer, 0, 646, False, 100, 0, 17, 1, Protocol.ItemClass.Normal, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0))
            returns.Add(CreateItem("Hard Glove", Protocol.ItemType.Bracer, 0, 643, False, 5000, 0, 17, 3, Protocol.ItemClass.Normal, 0, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0))
            '22 bracers
            returns.Add(CreateItem("Sorcery Bracelet", Protocol.ItemType.Bracer, 0, 702, False, 8000, 0, 22, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0))
            returns.Add(CreateItem("Tri Stone Band", Protocol.ItemType.Bracer, 0, 682, False, 8000, 0, 22, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0))
            'superior bracers
            returns.Add(CreateItem("Dragon Gauntlet", EvoLib.Protocol.mProtocol.ItemType.Bracer, 0, 662, False, 15000, 0, 11, 1, Protocol.ItemClass.Superior, , 1, , 1, , , , , 1, , 3, , , , , , , , , , , , , , , , , , , , , , , 11))
            returns.Add(CreateItem("Spell Bracelet", EvoLib.Protocol.ItemType.Bracer, 0, 703, False, 15000, 0, 11, 1, Protocol.ItemClass.Superior, , , 1, , 2, , , , 1, , , 2, , , , , , , , , , , , , , , , , , , , , , 7))
            returns.Add(CreateItem("Spiritual Bracelet", EvoLib.Protocol.mProtocol.ItemType.Bracer, 0, 683, False, 15000, 0, 11, 1, Protocol.ItemClass.Superior, , 1, , , , 1, , , 1, , , , 4, , , , , , , , , , , , , , , , , , , , , 9))

            'potions
            returns.Add(CreateItem("HP Potion (S)", Protocol.ItemType.Potion, 0, 6, True, 80, 1, 0, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
            returns.Add(CreateItem("MP Potion (S)", Protocol.ItemType.Potion, 0, 16, True, 84, 1, 0, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
            returns.Add(CreateItem("HP Potion (M)", Protocol.ItemType.Potion, 0, 7, True, 200, 1, 0, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 70, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
            returns.Add(CreateItem("MP Potion (M)", Protocol.ItemType.Potion, 0, 17, True, 200, 1, 0, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
            returns.Add(CreateItem("HP Potion (L)", Protocol.ItemType.Potion, 0, 8, True, 500, 1, 0, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
            returns.Add(CreateItem("MP Potion (L)", Protocol.ItemType.Potion, 0, 18, True, 500, 1, 0, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 180, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
            returns.Add(CreateItem("HP Potion (XL)", Protocol.ItemType.Potion, 0, 9, True, 1250, 1, 0, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 170, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
            returns.Add(CreateItem("MP Potion (XL)", Protocol.ItemType.Potion, 0, 19, True, 1250, 1, 0, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 250, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))

            'liquors
            returns.Add(CreateItem("Destruction Liquor (S)", Protocol.ItemType.Liquor, 0, 85, True, 10000, 2, 11, 3, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
            returns.Add(CreateItem("Spirit Liquor (S)", Protocol.ItemType.Liquor, 0, 82, True, 10000, 2, 11, 3, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
            returns.Add(CreateItem("Magic Liquor (S)", Protocol.ItemType.Liquor, 0, 84, True, 10000, 2, 11, 3, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))

            'teleport scrolls
            returns.Add(CreateItem("Town Teleport", Protocol.ItemType.Scroll, 0, 202, True, 550, 3, 0, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
            returns.Add(CreateItem("Random Teleport", Protocol.ItemType.Scroll, 0, 203, True, 220, 4, 0, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))

            'torches
            returns.Add(CreateItem("Candle", Protocol.ItemType.Torch, 0, 291, False, 110, 0, 1, 1, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0))
            returns.Add(CreateItem("Torch", Protocol.ItemType.Torch, 0, 292, False, 990, 0, 11, 3, Protocol.ItemClass.Normal, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0))

            'skill books
            returns.Add(CreateItem("Fireball", EvoLib.Protocol.mProtocol.ItemType.SorcererBook, Skills.Fireball, 305, False, 1500, 5, 7, 1, ItemClass.Rare, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
            returns.Add(CreateItem("Fencing", EvoLib.Protocol.mProtocol.ItemType.WarriorBook, Skills.Fencing, 305, False, 1500, 5, 7, 1, ItemClass.Rare, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
            returns.Add(CreateItem("Slaying", EvoLib.Protocol.mProtocol.ItemType.WarriorBook, Skills.Slaying, 305, False, 2200, 5, 11, 1, ItemClass.Rare, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
            returns.Add(CreateItem("Healing", EvoLib.Protocol.mProtocol.ItemType.TaoistBook, Skills.Healing, 305, False, 1500, 5, 7, 1, ItemClass.Rare, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
            returns.Add(CreateItem("Spirit Sword", EvoLib.Protocol.mProtocol.ItemType.TaoistBook, Skills.Spiritsword, 305, False, 2200, 5, 11, 1, ItemClass.Rare, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))

            'meat
            returns.Add(CreateItem("Chicken", EvoLib.Protocol.mProtocol.ItemType.Meat, 0, 302, False, 50, 0, 0, 1, Protocol.ItemClass.Normal, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , 20))
            returns.Add(CreateItem("Ham", EvoLib.Protocol.mProtocol.ItemType.Meat, 0, 301, False, 150, 0, 0, 1, Protocol.ItemClass.Normal, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , 20))
            returns.Add(CreateItem("Lamb", EvoLib.Protocol.mProtocol.ItemType.Meat, 0, 301, False, 250, 0, 0, 1, Protocol.ItemClass.Normal, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , 20))
            returns.Add(CreateItem("Beef", EvoLib.Protocol.mProtocol.ItemType.Meat, 0, 301, False, 400, 0, 0, 2, Protocol.ItemClass.Normal, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , 20))
            returns.Add(CreateItem("Venison", EvoLib.Protocol.mProtocol.ItemType.Meat, 0, 301, False, 550, 0, 0, 2, Protocol.ItemClass.Normal, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , 20))

            Dim okCount As Integer, failCount As Integer

            For Each result As Boolean In returns

                If result Then
                    okCount += 1
                Else
                    failCount += 1
                End If

            Next

            Debug.WriteLine("CreateDefaultItems(): Created " & okCount & " items and skipped " & failCount & " duplicates!")

        End Sub

        Private Sub CheckTables_Game_TBL_ITEMS()

            DB_Game.CheckTable("TBL_ITEMS", _
                                "ID_ITEM bigint PRIMARY KEY IDENTITY(1,1), " & _
                                "ID_ITEMBASE int NOT NULL, " & _
                                "ID_CHARACTER int NOT NULL, " & _
                                "INT_ALPHACOL int NOT NULL, " & _
                                "BYTE_LOCATION tinyint NOT NULL, " & _
                                "INT_COUNT int NOT NULL, " & _
                                "INT2_ITEMLEVEL smallint NOT NULL, " & _
                                "INT_ITEMEXP int NOT NULL, " & _
                                "INT2_ADD_MIN_AC smallint NOT NULL, " & _
                                "INT2_ADD_MIN_MAC smallint NOT NULL, " & _
                                "INT2_ADD_MIN_DC smallint NOT NULL, " & _
                                "INT2_ADD_MIN_MC smallint NOT NULL, " & _
                                "INT2_ADD_MIN_SC smallint NOT NULL, " & _
                                "INT2_ADD_MAX_HP smallint NOT NULL, " & _
                                "INT2_ADD_MAX_MP smallint NOT NULL, " & _
                                "INT2_ADD_MAX_AC smallint NOT NULL, " & _
                                "INT2_ADD_MAX_MAC smallint NOT NULL, " & _
                                "INT2_ADD_MAX_DC smallint NOT NULL, " & _
                                "INT2_ADD_MAX_MC smallint NOT NULL, " & _
                                "INT2_ADD_MAX_SC smallint NOT NULL, " & _
                                "INT2_ADD_MAX_WEIGHT smallint NOT NULL, " & _
                                "INT2_ADD_MAX_HANDWEIGHT smallint NOT NULL, " & _
                                "INT2_ADD_MAX_WEARWEIGHT smallint NOT NULL, " & _
                                "INT2_ADD_ELEMC_FIRE smallint NOT NULL, " & _
                                "INT2_ADD_ELEMC_ICE smallint NOT NULL, " & _
                                "INT2_ADD_ELEMC_LIGHT smallint NOT NULL, " & _
                                "INT2_ADD_ELEMC_WIND smallint NOT NULL, " & _
                                "INT2_ADD_ELEMC_HOLY smallint NOT NULL, " & _
                                "INT2_ADD_ELEMC_DARK smallint NOT NULL, " & _
                                "INT2_ADD_ELEMC_PHANTOM smallint NOT NULL, " & _
                                "INT2_ADD_ELEMAC_FIRE smallint NOT NULL, " & _
                                "INT2_ADD_ELEMAC_ICE smallint NOT NULL, " & _
                                "INT2_ADD_ELEMAC_LIGHT smallint NOT NULL, " & _
                                "INT2_ADD_ELEMAC_WIND smallint NOT NULL, " & _
                                "INT2_ADD_ELEMAC_HOLY smallint NOT NULL, " & _
                                "INT2_ADD_ELEMAC_DARK smallint NOT NULL, " & _
                                "INT2_ADD_ELEMAC_PHANTOM smallint NOT NULL, " & _
                                "INT1_ADD_ACCURACY tinyint NOT NULL, " & _
                                "INT1_ADD_AGILITY tinyint NOT NULL, " & _
                                "INT1_ADD_VELOCITY tinyint NOT NULL, " & _
                                "INT_ADD_MAX_DURABILITY int NOT NULL, " & _
                                "INT_DURABILITY int NOT NULL, " & _
                                "INT1_ADD_STRENGTH tinyint NOT NULL, " & _
                                "INT1_ADD_LUCK tinyint NOT NULL")


        End Sub

        Public Sub CheckTables_Game_TBL_MON()

            If DB_Game.CheckTable("TBL_MON", _
                                "ID_MON bigint PRIMARY KEY IDENTITY(1,1), " & _
                                "STR_NAME varchar(" & Protocol.MAX_MONNAME_LEN & ") NOT NULL, " & _
                                "INT2_SHAPE smallint NOT NULL, " & _
                                "INT2_LEVEL smallint NOT NULL, " & _
                                "BOOL_ISELITE bit NOT NULL, " & _
                                "BOOL_ISBOSS bit NOT NULL, " & _
                                "BOOL_ISTAMABLE bit NOT NULL, " & _
                                "BOOL_ISUNDEAD bit NOT NULL, " & _
                                "INT2_AI smallint NOT NULL, " & _
                                "INT2_MIN_AC smallint NOT NULL, " & _
                                "INT2_MIN_MAC smallint NOT NULL, " & _
                                "INT2_MIN_DC smallint NOT NULL, " & _
                                "INT2_MIN_MC smallint NOT NULL, " & _
                                "INT2_MAX_HP smallint NOT NULL, " & _
                                "INT2_MAX_MP smallint NOT NULL, " & _
                                "INT2_MAX_AC smallint NOT NULL, " & _
                                "INT2_MAX_MAC smallint NOT NULL, " & _
                                "INT2_MAX_DC smallint NOT NULL, " & _
                                "INT2_MAX_MC smallint NOT NULL, " & _
                                "INT2_ELEMC_FIRE smallint NOT NULL, " & _
                                "INT2_ELEMC_ICE smallint NOT NULL, " & _
                                "INT2_ELEMC_LIGHT smallint NOT NULL, " & _
                                "INT2_ELEMC_WIND smallint NOT NULL, " & _
                                "INT2_ELEMC_HOLY smallint NOT NULL, " & _
                                "INT2_ELEMC_DARK smallint NOT NULL, " & _
                                "INT2_ELEMC_PHANTOM smallint NOT NULL, " & _
                                "INT2_ELEMAC_FIRE smallint NOT NULL, " & _
                                "INT2_ELEMAC_ICE smallint NOT NULL, " & _
                                "INT2_ELEMAC_LIGHT smallint NOT NULL, " & _
                                "INT2_ELEMAC_WIND smallint NOT NULL, " & _
                                "INT2_ELEMAC_HOLY smallint NOT NULL, " & _
                                "INT2_ELEMAC_DARK smallint NOT NULL, " & _
                                "INT2_ELEMAC_PHANTOM smallint NOT NULL, " & _
                                "INT2_HEAL_POINTS smallint NOT NULL, " & _
                                "INT8_HEALSPEED bigint NOT NULL, " & _
                                "INT2_SPEED smallint NOT NULL, " & _
                                "INT2_HIT smallint NOT NULL, " & _
                                "INT8_WALKSPEED bigint NOT NULL, " & _
                                "BOOL_WALKSTEP bit NOT NULL, " & _
                                "INT8_ATTACKSPEED bigint NOT NULL, " & _
                                "INT8_EXP bigint NOT NULL, " & _
                                "INT2_AVATAR smallint NOT NULL") Then


                CreateMon("Hen", 20, 2, False, False, True, False, 0, 0, 0, 0, 0, 10, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 50000000, 5, 6, 15000000, True, 30000000, 5, 21)
                CreateMon("Pig", 119, 3, False, False, True, False, 0, 0, 0, 0, 0, 20, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 50000000, 5, 8, 15000000, True, 30000000, 8, 120)
                CreateMon("Bull", 121, 4, False, False, True, False, 0, 0, 0, 0, 0, 30, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 50000000, 5, 10, 15000000, True, 30000000, 11, 122)
                CreateMon("Sheep", 58, 5, False, False, True, False, 0, 0, 0, 0, 0, 40, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 50000000, 8, 7, 15000000, True, 30000000, 14, 59)
                CreateMon("Deer", 21, 6, False, False, True, False, 0, 0, 0, 0, 0, 50, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 50000000, 8, 9, 15000000, True, 30000000, 17, 22)


            End If

        End Sub

        Public Sub CreateMon(STR_NAME As String, _
                        INT2_SHAPE As Int16, _
                        INT2_LEVEL As Int16, _
                        BOOL_ISELITE As Boolean, _
                        BOOL_ISBOSS As Boolean, _
                        BOOL_ISTAMABLE As Boolean, _
                        BOOL_ISUNDEAD As Boolean, _
                        INT2_AI As Int16, _
                        INT2_MIN_AC As Int16, _
                        INT2_MIN_MAC As Int16, _
                        INT2_MIN_DC As Int16, _
                        INT2_MIN_MC As Int16, _
                        INT2_MAX_HP As Int16, _
                        INT2_MAX_MP As Int16, _
                        INT2_MAX_AC As Int16, _
                        INT2_MAX_MAC As Int16, _
                        INT2_MAX_DC As Int16, _
                        INT2_MAX_MC As Int16, _
                        INT2_ELEMC_FIRE As Int16, _
                        INT2_ELEMC_ICE As Int16, _
                        INT2_ELEMC_LIGHT As Int16, _
                        INT2_ELEMC_WIND As Int16, _
                        INT2_ELEMC_HOLY As Int16, _
                        INT2_ELEMC_DARK As Int16, _
                        INT2_ELEMC_PHANTOM As Int16, _
                        INT2_ELEMAC_FIRE As Int16, _
                        INT2_ELEMAC_ICE As Int16, _
                        INT2_ELEMAC_LIGHT As Int16, _
                        INT2_ELEMAC_WIND As Int16, _
                        INT2_ELEMAC_HOLY As Int16, _
                        INT2_ELEMAC_DARK As Int16, _
                        INT2_ELEMAC_PHANTOM As Int16, _
                        INT2_HEAL_POINTS As Int16, _
                        INT8_HEALSPEED As Long, _
                        INT2_SPEED As Int16, _
                        INT2_HIT As Int16, _
                        INT8_WALKSPEED As Long, _
                        BOOL_WALKSTEP As Boolean, _
                        INT8_ATTACKSPEED As Long, _
                        INT8_EXP As Long, _
                        INT2_AVATAR As Int16)

            Dim cols() As String = {"STR_NAME", _
                        "INT2_SHAPE", _
                        "INT2_LEVEL", _
                        "BOOL_ISELITE", _
                        "BOOL_ISBOSS", _
                        "BOOL_ISTAMABLE", _
                        "BOOL_ISUNDEAD", _
                        "INT2_AI", _
                        "INT2_MIN_AC", _
                        "INT2_MIN_MAC", _
                        "INT2_MIN_DC", _
                        "INT2_MIN_MC", _
                        "INT2_MAX_HP", _
                        "INT2_MAX_MP", _
                        "INT2_MAX_AC", _
                        "INT2_MAX_MAC", _
                        "INT2_MAX_DC", _
                        "INT2_MAX_MC", _
                        "INT2_ELEMC_FIRE", _
                        "INT2_ELEMC_ICE", _
                        "INT2_ELEMC_LIGHT", _
                        "INT2_ELEMC_WIND", _
                        "INT2_ELEMC_HOLY", _
                        "INT2_ELEMC_DARK", _
                        "INT2_ELEMC_PHANTOM", _
                        "INT2_ELEMAC_FIRE", _
                        "INT2_ELEMAC_ICE", _
                        "INT2_ELEMAC_LIGHT", _
                        "INT2_ELEMAC_WIND", _
                        "INT2_ELEMAC_HOLY", _
                        "INT2_ELEMAC_DARK", _
                        "INT2_ELEMAC_PHANTOM", _
                        "INT2_HEAL_POINTS", _
                        "INT8_HEALSPEED", _
                        "INT2_SPEED", _
                        "INT2_HIT", _
                        "INT8_WALKSPEED", _
                        "BOOL_WALKSTEP", _
                        "INT8_ATTACKSPEED", _
                        "INT8_EXP", _
                        "INT2_AVATAR"}

            Dim vals() As String = {"'" & STR_NAME & "'", _
                        INT2_SHAPE, _
                        INT2_LEVEL, _
                        "'" & BOOL_ISELITE.ToString & "'", _
                        "'" & BOOL_ISBOSS.ToString & "'", _
                        "'" & BOOL_ISTAMABLE.ToString & "'", _
                        "'" & BOOL_ISUNDEAD.ToString & "'", _
                        INT2_AI, _
                        INT2_MIN_AC, _
                        INT2_MIN_MAC, _
                        INT2_MIN_DC, _
                        INT2_MIN_MC, _
                        INT2_MAX_HP, _
                        INT2_MAX_MP, _
                        INT2_MAX_AC, _
                        INT2_MAX_MAC, _
                        INT2_MAX_DC, _
                        INT2_MAX_MC, _
                        INT2_ELEMC_FIRE, _
                        INT2_ELEMC_ICE, _
                        INT2_ELEMC_LIGHT, _
                        INT2_ELEMC_WIND, _
                        INT2_ELEMC_HOLY, _
                        INT2_ELEMC_DARK, _
                        INT2_ELEMC_PHANTOM, _
                        INT2_ELEMAC_FIRE, _
                        INT2_ELEMAC_ICE, _
                        INT2_ELEMAC_LIGHT, _
                        INT2_ELEMAC_WIND, _
                        INT2_ELEMAC_HOLY, _
                        INT2_ELEMAC_DARK, _
                        INT2_ELEMAC_PHANTOM, _
                        INT2_HEAL_POINTS, _
                        INT8_HEALSPEED, _
                        INT2_SPEED, _
                        INT2_HIT, _
                        INT8_WALKSPEED, _
                        "'" & BOOL_WALKSTEP.ToString & "'", _
                        INT8_ATTACKSPEED, _
                        INT8_EXP, _
                        INT2_AVATAR}

            DB_Game.NewRecord("TBL_MON", cols, vals)

        End Sub

        Public Sub CheckTables_Game_TBL_MONSPAWN()

            If DB_Game.CheckTable("TBL_MONSPAWN", _
                                "STR_MAPNAME varchar(" & Protocol.MAX_MAPFILE_LEN & ") NOT NULL, " & _
                                "ID_MON bigint NOT NULL, " & _
                                "INT2_X smallint NOT NULL, " & _
                                "INT2_Y smallint NOT NULL, " & _
                                "INT2_RANGEX smallint NOT NULL, " & _
                                "INT2_RANGEY smallint NOT NULL, " & _
                                "INT2_COUNT smallint NOT NULL") Then

                CreateSpawn("10", "Hen", 310, 270, 100, 100, 250)
                CreateSpawn("10", "Pig", 310, 270, 100, 100, 150)
                CreateSpawn("10", "Bull", 310, 270, 100, 100, 75)
                CreateSpawn("10", "Sheep", 310, 270, 100, 100, 110)
                CreateSpawn("10", "Deer", 310, 270, 100, 100, 110)

            End If



        End Sub

        Public Sub CreateSpawn(STR_MAPNAME As String, _
                                STR_NAME As String, _
                                INT2_X As Int16, _
                                INT2_Y As Int16, _
                                INT2_RANGEX As Int16, _
                                INT2_RANGEY As Int16, _
                                INT2_COUNT As Int16)

            Dim cols() As String = {"STR_MAPNAME", _
                                "ID_MON", _
                                "INT2_X", _
                                "INT2_Y", _
                                "INT2_RANGEX", _
                                "INT2_RANGEY", _
                                "INT2_COUNT"}


            Dim ssql As String = "SELECT ID_MON FROM TBL_MON WHERE STR_NAME='" & STR_NAME & "';"
            Dim row As Collection = DB_Game.ExecuteQueryFirstRecord(ssql)

            If Not row Is Nothing Then
                If row.Count > 0 Then

                    Dim vals() As String = {STR_MAPNAME, _
                                        row("ID_MON"), _
                                        INT2_X, _
                                        INT2_Y, _
                                        INT2_RANGEX, _
                                        INT2_RANGEY, _
                                        INT2_COUNT}


                    DB_Game.NewRecord("TBL_MONSPAWN", cols, vals)

                End If
            End If

        End Sub


        Private Sub CheckTables_Game_TBL_XSERVERCONN()

            DB_Game.CheckTable("TBL_XSERVERCONN", _
                                "STR_IPADDRESS varchar(15) NOT NULL, " & _
                                "STR_UNAME varchar(" & MAX_USERNAME_LEN & ") NOT NULL, " & _
                                "STR_DESTSERVER varchar(32) NOT NULL, " & _
                                "ID_LOGIN int NOT NULL, " & _
                                "ID_CHARACTER int NOT NULL, " & _
                                "STR_MAP varchar(" & MAX_MAPFILE_LEN & ") NOT NULL, " & _
                                "INT_X int NOT NULL, " & _
                                "INT_Y int NOT NULL")


        End Sub

        Private Sub CheckTables_Game_TBL_LEVELS()

            If DB_Game.CheckTable("TBL_LEVELS", _
                                "INT_LVL int NOT NULL, " & _
                                "INT_EXP bigint NOT NULL") Then

                Dim cols() As String = {"INT_LVL", "INT_EXP"}
                Dim vals() As String = {"1", "100"}
                DB_Game.NewRecord("TBL_LEVELS", cols, vals)
                vals = {"2", "200"}
                DB_Game.NewRecord("TBL_LEVELS", cols, vals)
                vals = {"3", "300"}
                DB_Game.NewRecord("TBL_LEVELS", cols, vals)
                vals = {"4", "400"}
                DB_Game.NewRecord("TBL_LEVELS", cols, vals)
                vals = {"5", "500"}
                DB_Game.NewRecord("TBL_LEVELS", cols, vals)
                vals = {"6", "600"}
                DB_Game.NewRecord("TBL_LEVELS", cols, vals)
                vals = {"7", "700"}
                DB_Game.NewRecord("TBL_LEVELS", cols, vals)
                vals = {"8", "800"}
                DB_Game.NewRecord("TBL_LEVELS", cols, vals)
                vals = {"9", "900"}
                DB_Game.NewRecord("TBL_LEVELS", cols, vals)
                vals = {"10", "1000"}
                DB_Game.NewRecord("TBL_LEVELS", cols, vals)

            End If


        End Sub

        Private Sub CheckTables_Game_TBL_SKILLBOOK()

            DB_Game.CheckTable("TBL_SKILLBOOK", _
                                "ID_CHARACTER bigint NOT NULL, " & _
                                "BYTE_LEVEL tinyint NOT NULL, " & _
                                "BYTE_SKILL tinyint NOT NULL, " & _
                                "INT8_EXP bigint NOT NULL")

        End Sub

        Private Sub CheckTables_Game_TBL_SKILLLEVELS()

            If DB_Game.CheckTable("TBL_SKILLLEVELS", _
                                "BYTE_SKILL tinyint NOT NULL, " & _
                                "BYTE_LEVEL tinyint NOT NULL, " & _
                                "BYTE_PLAYERLEVEL tinyint NOT NULL, " & _
                                "INT8_TOTALEXP bigint NOT NULL") Then

                Dim cols() As String = {"BYTE_SKILL", "BYTE_LEVEL", "INT8_TOTALEXP", "BYTE_PLAYERLEVEL"}

                Dim vals() As String = {Skills.Fireball, 0, 50, 7}
                DB_Game.NewRecord("TBL_SKILLLEVELS", cols, vals)
                vals = {Skills.Fireball, 1, 100, 9}
                DB_Game.NewRecord("TBL_SKILLLEVELS", cols, vals)
                vals = {Skills.Fireball, 2, 150, 11}
                DB_Game.NewRecord("TBL_SKILLLEVELS", cols, vals)
                vals = {Skills.Fireball, 3, -1, 13}
                DB_Game.NewRecord("TBL_SKILLLEVELS", cols, vals)
                vals = {Skills.Fireball, 4, -1, 15}
                DB_Game.NewRecord("TBL_SKILLLEVELS", cols, vals)

                vals = {Skills.Fencing, 0, 50, 7}
                DB_Game.NewRecord("TBL_SKILLLEVELS", cols, vals)
                vals = {Skills.Fencing, 1, 100, 9}
                DB_Game.NewRecord("TBL_SKILLLEVELS", cols, vals)
                vals = {Skills.Fencing, 2, 150, 11}
                DB_Game.NewRecord("TBL_SKILLLEVELS", cols, vals)
                vals = {Skills.Fencing, 3, -1, 13}
                DB_Game.NewRecord("TBL_SKILLLEVELS", cols, vals)
                vals = {Skills.Fencing, 4, -1, 15}
                DB_Game.NewRecord("TBL_SKILLLEVELS", cols, vals)

                vals = {Skills.Slaying, 0, 75, 9}
                DB_Game.NewRecord("TBL_SKILLLEVELS", cols, vals)
                vals = {Skills.Slaying, 1, 125, 11}
                DB_Game.NewRecord("TBL_SKILLLEVELS", cols, vals)
                vals = {Skills.Slaying, 2, 175, 13}
                DB_Game.NewRecord("TBL_SKILLLEVELS", cols, vals)
                vals = {Skills.Slaying, 3, -1, 15}
                DB_Game.NewRecord("TBL_SKILLLEVELS", cols, vals)
                vals = {Skills.Slaying, 4, -1, 17}
                DB_Game.NewRecord("TBL_SKILLLEVELS", cols, vals)

                vals = {Skills.Healing, 0, 50, 7}
                DB_Game.NewRecord("TBL_SKILLLEVELS", cols, vals)
                vals = {Skills.Healing, 1, 100, 9}
                DB_Game.NewRecord("TBL_SKILLLEVELS", cols, vals)
                vals = {Skills.Healing, 2, 150, 11}
                DB_Game.NewRecord("TBL_SKILLLEVELS", cols, vals)
                vals = {Skills.Healing, 3, -1, 13}
                DB_Game.NewRecord("TBL_SKILLLEVELS", cols, vals)
                vals = {Skills.Healing, 4, -1, 15}
                DB_Game.NewRecord("TBL_SKILLLEVELS", cols, vals)

                vals = {Skills.Spiritsword, 0, 75, 9}
                DB_Game.NewRecord("TBL_SKILLLEVELS", cols, vals)
                vals = {Skills.Spiritsword, 1, 125, 11}
                DB_Game.NewRecord("TBL_SKILLLEVELS", cols, vals)
                vals = {Skills.Spiritsword, 2, 175, 13}
                DB_Game.NewRecord("TBL_SKILLLEVELS", cols, vals)
                vals = {Skills.Spiritsword, 3, -1, 15}
                DB_Game.NewRecord("TBL_SKILLLEVELS", cols, vals)
                vals = {Skills.Spiritsword, 4, -1, 17}
                DB_Game.NewRecord("TBL_SKILLLEVELS", cols, vals)

            End If

        End Sub

        Private Sub CheckTables_Game_TBL_SKILLDESC()

            If DB_Game.CheckTable("TBL_SKILLDESC", _
                                "BYTE_SKILL tinyint NOT NULL, " & _
                                "STR_DESC varchar(" & Protocol.MAX_SKILLDESC_LEN & ") NOT NULL") Then

                Dim cols() As String = {"BYTE_SKILL", "STR_DESC"}

                Dim vals() As String = {Skills.Fireball, "'Hurls a fireball at the target'"}
                DB_Game.NewRecord("TBL_SKILLDESC", cols, vals)

                vals = {Skills.Fencing, "'Increases accuracy'"}
                DB_Game.NewRecord("TBL_SKILLDESC", cols, vals)

                vals = {Skills.Slaying, "'Increases melle damage'"}
                DB_Game.NewRecord("TBL_SKILLDESC", cols, vals)

                vals = {Skills.Healing, "'Heals the target'"}
                DB_Game.NewRecord("TBL_SKILLDESC", cols, vals)

                vals = {Skills.Spiritsword, "'Increases accuracy and damage'"}
                DB_Game.NewRecord("TBL_SKILLDESC", cols, vals)

            End If

        End Sub

        Private Sub CheckTables_Game_TBL_SKILLMAPPINGS()

            DB_Game.CheckTable("TBL_SKILLMAPPINGS", _
                                "ID_CHARACTER bigint NOT NULL, " & _
                                "BYTE_KEY tinyint NOT NULL, " & _
                                "BYTE_SET tinyint NOT NULL, " & _
                                "BYTE_SKILL tinyint NOT NULL")

        End Sub

#End Region

#Region "Game Functions"

        Public Function CreateItem(ByVal name As String, ByVal type As Protocol.ItemType, ByVal shape As Integer, ByVal looks As Integer, ByVal stacks As Boolean, ByVal cost As Long, ByVal stditem As Integer, _
                              ByVal levelreq As Int16, ByVal weight As Int16, ByVal itemclass As Protocol.ItemClass, Optional ByVal expbonus As Byte = 0, Optional ByVal minac As Int16 = 0, _
                               Optional ByVal minmac As Int16 = 0, Optional ByVal mindc As Int16 = 0, Optional ByVal minmc As Int16 = 0, Optional ByVal minsc As Int16 = 0, Optional ByVal hp As Int16 = 0, Optional ByVal mp As Int16 = 0, _
                              Optional ByVal maxac As Int16 = 0, Optional ByVal maxmac As Int16 = 0, Optional ByVal maxdc As Int16 = 0, Optional ByVal maxmc As Int16 = 0, Optional ByVal maxsc As Int16 = 0, Optional ByVal bagweight As Int16 = 0, _
                              Optional ByVal handweight As Int16 = 0, Optional ByVal wearweight As Int16 = 0, _
                              Optional ByVal elemcfire As Int16 = 0, Optional ByVal elemcice As Int16 = 0, Optional ByVal elemclight As Int16 = 0, Optional ByVal elemcwind As Int16 = 0, Optional ByVal elemcholy As Int16 = 0, Optional ByVal elemcdark As Int16 = 0, Optional ByVal elemcphantom As Int16 = 0, _
                              Optional ByVal elemacfire As Int16 = 0, Optional ByVal elemacice As Int16 = 0, Optional ByVal elemaclight As Int16 = 0, Optional ByVal elemacwind As Int16 = 0, Optional ByVal elemacholy As Int16 = 0, Optional ByVal elemacdark As Int16 = 0, Optional ByVal elemacphantom As Int16 = 0, _
                              Optional ByVal accuracy As Byte = 0, Optional ByVal agility As Byte = 0, Optional ByVal velocity As Byte = 0, Optional ByVal maxdura As Integer = 0, Optional ByVal strength As Byte = 0, Optional ByVal luck As Byte = 0) As Boolean



            Dim ssql As String = "SELECT * FROM TBL_ITEMBASE WHERE STR_NAME='" & name & "';"
            Dim row As Collection = DB_Game.ExecuteQueryFirstRecord(ssql)

            If row Is Nothing Then
                Debug.WriteLine("CreateItem() failed due to an error checking the database for a matching name! Possibly (GameEvo)TBL_ITEMBASE does not exist")
                Return False
            ElseIf row.Count > 0 Then
                Debug.WriteLine("CreateItem() did not create '" & name & "' as it already exists!")
                Return False
            Else

                Dim cols() As String = {"STR_NAME", "BYTE_TYPE", "INT_SHAPE", "INT_LOOKS", "BOOL_STACKS", "INT8_COST", "INT_STDITEM", "INT2_LEVELREQ", "INT2_WEIGHT", "BYTE_ITEMCLASS", "INT1_EXPBONUS", "INT2_MIN_AC", "INT2_MIN_MAC", "INT2_MIN_DC", _
                                    "INT2_MIN_MC", "INT2_MIN_SC", "INT2_MAX_HP", "INT2_MAX_MP", "INT2_MAX_AC", "INT2_MAX_MAC", "INT2_MAX_DC", "INT2_MAX_MC", "INT2_MAX_SC", "INT2_MAX_WEIGHT", "INT2_MAX_HANDWEIGHT", "INT2_MAX_WEARWEIGHT", _
                                    "INT2_ELEMC_FIRE", "INT2_ELEMC_ICE", "INT2_ELEMC_LIGHT", "INT2_ELEMC_WIND", "INT2_ELEMC_HOLY", "INT2_ELEMC_DARK", "INT2_ELEMC_PHANTOM", "INT2_ELEMAC_FIRE", "INT2_ELEMAC_ICE", "INT2_ELEMAC_LIGHT", _
                                    "INT2_ELEMAC_WIND", "INT2_ELEMAC_HOLY", "INT2_ELEMAC_DARK", "INT2_ELEMAC_PHANTOM", "INT1_ACCURACY", "INT1_AGILITY", "INT1_VELOCITY", "INT_MAX_DURABILITY", "INT1_STRENGTH", "INT1_LUCK"}



                Dim vals() As String = {"'" & name & "'", type, shape, looks, "'" & stacks & "'", cost, stditem, levelreq, weight, itemclass, expbonus, minac, minmac, mindc, minmc, _
                                        minsc, hp, mp, maxac, maxmac, maxdc, maxmc, maxsc, bagweight, handweight, wearweight, _
                                        elemcfire, elemcice, elemclight, elemcwind, elemcholy, elemcdark, elemcphantom, _
                                        elemacfire, elemacice, elemaclight, elemacwind, elemacholy, elemacdark, elemacphantom, _
                                        accuracy, agility, velocity, maxdura, strength, luck}

                DB_Game.NewRecord("TBL_ITEMBASE", cols, vals)
                Debug.WriteLine("CreateItem() succeeded (" & name & ")")
                Return True
            End If


        End Function

        Public Sub UpdateItem(ByVal ID_ITEMBASE As Int64, ByVal name As String, ByVal type As Protocol.ItemType, ByVal shape As Integer, ByVal looks As Integer, ByVal stacks As Boolean, ByVal stditem As Integer, _
                      ByVal levelreq As Int16, ByVal weight As Int16, ByVal itemclass As Protocol.ItemClass, ByVal expbonus As Byte, ByVal minac As Int16, _
                      ByVal minmac As Int16, ByVal mindc As Int16, ByVal minmc As Int16, ByVal minsc As Int16, ByVal hp As Int16, ByVal mp As Int16, _
                      ByVal maxac As Int16, ByVal maxmac As Int16, ByVal maxdc As Int16, ByVal maxmc As Int16, ByVal maxsc As Int16, ByVal bagweight As Int16, _
                      ByVal handweight As Int16, ByVal wearweight As Int16, _
                      ByVal elemcfire As Int16, ByVal elemcice As Int16, ByVal elemclight As Int16, ByVal elemcwind As Int16, ByVal elemcholy As Int16, ByVal elemcdark As Int16, ByVal elemcphantom As Int16, _
                      ByVal elemacfire As Int16, ByVal elemacice As Int16, ByVal elemaclight As Int16, ByVal elemacwind As Int16, ByVal elemacholy As Int16, ByVal elemacdark As Int16, ByVal elemacphantom As Int16, _
                      ByVal accuracy As Byte, ByVal agility As Byte, ByVal velocity As Byte, ByVal maxdura As Integer, ByVal strength As Byte, ByVal luck As Byte)

            Dim cols() As String = {"STR_NAME", "BYTE_TYPE", "INT_SHAPE", "INT_LOOKS", "BOOL_STACKS", "INT_STDITEM", "INT2_LEVELREQ", "INT2_WEIGHT", "BYTE_ITEMCLASS", "INT1_EXPBONUS", "INT2_MIN_AC", "INT2_MIN_MAC", "INT2_MIN_DC", _
                                "INT2_MIN_MC", "INT2_MIN_SC", "INT2_MAX_HP", "INT2_MAX_MP", "INT2_MAX_AC", "INT2_MAX_MAC", "INT2_MAX_DC", "INT2_MAX_MC", "INT2_MAX_SC", "INT2_MAX_WEIGHT", "INT2_MAX_HANDWEIGHT", "INT2_MAX_WEARWEIGHT", _
                                "INT2_ELEMC_FIRE", "INT2_ELEMC_ICE", "INT2_ELEMC_LIGHT", "INT2_ELEMC_WIND", "INT2_ELEMC_HOLY", "INT2_ELEMC_DARK", "INT2_ELEMC_PHANTOM", "INT2_ELEMAC_FIRE", "INT2_ELEMAC_ICE", "INT2_ELEMAC_LIGHT", _
                                "INT2_ELEMAC_WIND", "INT2_ELEMAC_HOLY", "INT2_ELEMAC_DARK", "INT2_ELEMAC_PHANTOM", "INT1_ACCURACY", "INT1_AGILITY", "INT1_VELOCITY", "INT_MAX_DURABILITY", "INT1_STRENGTH", "INT1_LUCK"}



            Dim vals() As String = {"'" & name & "'", type, shape, looks, "'" & stacks & "'", stditem, levelreq, weight, itemclass, expbonus, minac, minmac, mindc, minmc, _
                                    minsc, hp, mp, maxac, maxmac, maxdc, maxmc, maxsc, bagweight, handweight, wearweight, _
                                    elemcfire, elemcice, elemclight, elemcwind, elemcholy, elemcdark, elemcphantom, _
                                    elemacfire, elemacice, elemaclight, elemacwind, elemacholy, elemacdark, elemacphantom, _
                                    accuracy, agility, velocity, maxdura, strength, luck}


            'construct an SQL query to update the ItemBase to the values on the form
            Dim sSql As String = "UPDATE TBL_ITEMBASE SET "

            For i As Integer = cols.GetLowerBound(0) To cols.GetUpperBound(0)
                sSql &= (cols(i) & "=" & vals(i) & ", ")
            Next

            sSql = Left(sSql, sSql.Length - 2) & " WHERE ID_ITEMBASE='" & ID_ITEMBASE & "';"

            'execute the query, updating the ItemBase entry
            DB_Game.ExecuteNonQuery(sSql)


        End Sub

#End Region

#End Region

#Region "Debug Output"

        Private Sub DB_Account_WriteConsoleLine(ByVal strText As String) Handles DB_Account.WriteConsoleLine
            Debug.Print(strText)
        End Sub

        Private Sub DB_Game_WriteConsoleLine(ByVal strText As String) Handles DB_Game.WriteConsoleLine
            Debug.Print(strText)
        End Sub

#End Region

    End Module

End Namespace
